package com.itheima.day10.myStream.test5;

import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;

/*
Stream流的终结方法
 */
public class Demo {
    public static void main(String[] args) {
        HashSet<String> hs = new HashSet<>(Set.of("AAA", "BBB", "CCC", "DDD", "aaa"));
        System.out.println(hs);

        // forEach(hs);

        // count(hs);

    }

    private static void count(HashSet<String> hs) {
        long count = hs.stream().count();
        System.out.println(count);
    }

    private static void forEach(HashSet<String> hs) {
        hs.stream().forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });
        System.out.println("======================");

        hs.stream().forEach((String s) -> {
            System.out.println(s);
        });
        System.out.println("======================");

        hs.stream().forEach(s -> System.out.println(s));
    }
}
